package com.example.pay_service.Dao;

import com.example.pay_service.vo.Address;
import com.example.pay_service.vo.Commodity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @title: ShopcartDao
 * @projectName mall
 * @description: TODO
 * @author TLJ
 * @date 2021/12/1411:26
 */
@Repository
@Mapper
public interface ShopcartDao {

    @Select("SELECT a.id , a.commodity_name , a.commodity_price ,a.commodity_picture, a.commodity_description , b.attribute FROM t_commodity a , t_commodity_allocation b WHERE a.id = b.id and a.id = #{id}")
   @Results({
           @Result(property = "id",column = "id"),
           @Result(property = "commodity_name" ,column = "commodity_name"),
           @Result(property = "commodity_price", column = "commodity_price"),
           @Result(property = "commodity_description",column = "commodity_description"),
           @Result(property = "commodity_picture",column = "commodity_picture"),
           @Result(property = "attribute",column = "attribute")

   })
    Commodity show(int id);

    @Select("select * from address where user_id=#{user_id}")
    @Results({
            @Result(property = "addressid",column = "addressid"),
            @Result(property = "user_id" ,column = "user_id"),
            @Result(property = "addressname", column = "addressname"),
            @Result(property = "addressphone",column = "addressphone"),
            @Result(property = "addresscode",column = "addresscode"),
            @Result(property = "province",column = "province"),
            @Result(property = "scity",column = "scity"),
            @Result(property = "area",column = "area"),
            @Result(property = "town",column = "town"),
            @Result(property = "addressdetailed",column = "addressdetailed"),
            @Result(property = "status",column = "status"),


    })
    List<Address> showaddress(String user_id);
}
